@extends('master')

@section('title', '招聘分类管理')

@section('content')
<div class="row">
	<div class="col-md-12">
		@include('message')
		<p class="lead">
			招聘分类
			<a class="btn btn-info btn-xs" id="category_add_btn" href="#">添加新分类</a>
		</p>

	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<form class="form-inline" role="form" action="<% route('admin.category.store') %>" method="POST">
			<div class="form-group">
				<label class="sr-only" for="categoryName">分类标题</label>
				<input type="text" class="form-control" id="categoryName" name="name" placeholder="分类标题" />
			</div>

			<button type="submit" class="btn btn-default" id="category_submit" disabled>添加</button>
		</form>
		@if($categories->count())
		<div class="table-responsive" style="margin-top:10px;background-color:#fff;">
			<table class="table table-hover">
				<thead>
					<tr>
						<th>标题</th>
						<th>职位数</th>
						<th>日期</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					@foreach($categories as $category)
					<tr>
						<td>
							<% $category->name %>
						</td>
						<td>
							<span class="badge"><% $category->jobs->count() %></span>
						</td>
						<td>
							<% $category->created_at->format('Y-m-d') %>
						</td>
						<td>
							<% Form::open(array('route' => array('admin.category.destroy', $category->id), 'method' => 'DELETE', 'class' => 'delete-form form-inline invisible')) %>
								<button type="submit" class="btn btn-link btn-xs" onclick="if(!confirm('警告！如果你删除该分类，该分类下的所有职位均将被删除。你确定吗？')){ return false; }">删除</button>
							<% Form::close() %>
						</td>
					</tr>
					@endforeach
				</tbody>
				<tfoot>
					<tr>
						<th>标题</th>
						<th>类别</th>
						<th>日期</th>
						<th>操作</th>
					</tr>
				</tfoot>
			</table>
		</div>
		@else
		<br />
		<div class="alert alert-warning alert-dismissible" role="alert">
			<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  			<strong>还没有分类？</strong> 点击上方的“添加新分类”添加吧.
		</div>
		@endif
	</div>
</div>
@stop